<template>
  <div class="app-container ">
    <el-form ref="form" size="mini" :model="form" :rules="rules" label-width="180px">
      <el-tabs v-model="activeName">
        <el-tab-pane style="padding-top:10px" label="大转盘设置" name="大转盘设置">
          <el-row>
            <el-col :span="24">
              <el-form-item label="活动标题" prop="title">
                <el-input v-model="form.title" auto-complete="off" clearable placeholder="请输入活动标题" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="开始时间" prop="begin_time">
                <el-date-picker
                  v-model="form.begin_time"
                  type="datetime"
                  placeholder="选择日期时间"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="结速时间">
                <el-date-picker
                  v-model="form.end_time"
                  type="datetime"
                  placeholder="选择日期时间"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="抽奖规则" prop="participate_rules">
                <el-radio-group v-model="form.participate_rules">
                  <el-radio label="1">人/次</el-radio>
                  <el-radio label="2">天/次</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="抽奖次数" prop="participate_num">
                <el-input-number v-model="form.participate_num" controls-position="right" style="width:260px;" auto-complete="off"
                  clearable :min="0" placeholder="抽奖次数" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item :label="'需要'+lang.points" prop="pay_points">
                <el-input-number v-model="form.pay_points" controls-position="right" style="width:260px;" auto-complete="off"
                  clearable :min="0" :placeholder="'需要'+lang.points" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="抽奖说明">
                <el-input v-model="form.content" type="textarea" auto-complete="off"
                  :autosize="{ minRows: 10, maxRows: 20}" clearable placeholder="请输入抽奖说明" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="状态">
                <el-radio-group v-model="form.status">
                  <el-radio label="0">关闭</el-radio>
                  <el-radio label="1">开启</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
      <el-form-item>
        <el-button size="mini" type="primary" @click="submit">保存设置</el-button>
      </el-form-item>
    </el-form>

  </div>
</template>
<script>
export default {
  name: 'Configrotarytable',
  components: {},
  data() {
    return {
      lang: {},
      form: {
      },
      loading: false,
      activeName: '大转盘设置',
      rules: {}
    }
  },
  mounted() {
    this.$api.post('/Lang/getlang').then(res => {
      this.lang = res.data
    })
    this.$api.post('/config/getInfo', {
      mo: 'rotarytable'
    }).then(res => {
      this.form = JSON.stringify(res.data) == '[]' ? {} : res.data
    })
  },
  methods: {
    submit() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.loading = true
          this.$api.post('/config/update', this.form).then(res => {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
          }).catch(() => {
            this.loading = false
          })
        }
      })
    }
  }
}
</script>
